In [2]:
%matplotlib qt4
from __future__ import division
from models import tools, optimize, models, filters
from models.tests import PerformanceTest
import numpy as np
import pandas as pd
import sklearn as sk
import matplotlib.pyplot as plt
In [4]:
data = tools.load_data(offset=5e6, limit=1e6)
data = data[filters.place_type(data, 'river') & filters.for_staircase(data)]
print len(data)
In [3]:
data = tools.add_last_trial_age(data)
In [19]:
only_old = lambda d: d[d['last_trial_age'] > 60*60*6]
only_new = lambda d: d[d['last_trial_age'] < 60*60*6]
In [5]:
elo_test = PerformanceTest(models.EloModel(), data, split_data=True)
elo_test.run()
elo_test.results['train']
Out[5]:
In [6]:
elot_test = PerformanceTest(models.EloResponseTime(), data, split_data=True)
elot_test.run()
elot_test.results['train']
Out[6]:
In [5]:
pfa = models.PFAModel(models.EloModel(), gamma=1.545, delta=-0.21)
pfa_test = PerformanceTest(pfa, data).run()
pfa_test.get_results()
Out[5]:
In [20]:
pfa_test.get_results(only_new)
Out[20]:
In [21]:
pfa_test.get_results(only_old)
Out[21]:
In [6]:
pfae = models.PFAExt(models.EloModel(), gamma=2.92, delta=-0.759)
pfae_test = PerformanceTest(pfae, data).run()
pfae_test.get_results()
Out[6]:
In [22]:
pfae_test.get_results(only_new)
Out[22]:
In [24]:
pfae_test.get_results(only_old)
Out[24]:
In [9]:
pfag = models.PFAGong(models.EloModel(), gamma=2.024, delta=0.066, decay=0.434)
pfag_test = PerformanceTest(pfag, data).run()
pfag_test.get_results()
Out[9]:
In [25]:
pfag_test.get_results(only_new)
Out[25]:
In [26]:
pfag_test.get_results(only_old)
Out[26]:
In [35]:
pfaet = models.PFAExtTiming(models.EloModel(), gamma=2.004, delta=-0.713,
time_effect_fun='pow', a=2.931, c=0.27)
pfaet_test = PerformanceTest(pfaet, data).run()
pfaet_test.get_results()
Out[35]:
In [36]:
pfaet_test.get_results(only_new)
Out[36]:
In [37]:
pfaet_test.get_results(only_old)
Out[37]:
In [38]:
pfaet = models.PFAExtTiming(models.EloModel(), gamma=1.906, delta=-0.806,
time_effect_fun='log', a=1.789, c=0.128)
pfaet_test = PerformanceTest(pfaet, data).run()
pfaet_test.get_results()
Out[38]:
In [39]:
pfaet_test.get_results(only_new)
Out[39]:
In [40]:
pfaet_test.get_results(only_old)
Out[40]:
In [10]:
pfaet = models.PFAExtTiming(models.EloModel(), gamma=2.006, delta=-0.757,
time_effect_fun='exp', a=1.005, c=0.009)
pfaet_test = PerformanceTest(pfaet, data).run()
pfaet_test.get_results()
Out[10]:
In [27]:
pfaet_test.get_results(only_new)
Out[27]:
In [28]:
pfaet_test.get_results(only_old)
Out[28]:
In [11]:
staircase = {
(0, 60): 1.43,
(60, 90): 1.17,
(90, 150): 1.01,
(150, 300): 0.93,
(300, 600): 0.82,
(600, 60*30): 0.78,
(60*30, 60*60*3): 0.76,
(60*60*3, 60*60*24): 0.63,
(60*60*24, 60*60*24*5): 0.42,
(60*60*24*5, np.inf): 0.12,
}
pfaest = models.PFAExtStaircase(models.EloModel(), staircase=staircase,
gamma=1.814, delta=-0.827)
pfaest_test = PerformanceTest(pfaest, data).run()
pfaest_test.get_results()
Out[11]:
In [29]:
pfaest_test.get_results(only_new)
Out[29]:
In [30]:
pfaest_test.get_results(only_old)
Out[30]:
In [11]:
x = [0, 40.7, 74.7, 115.7, 205.6, 415.1, 1023.5, 4635.0, 48792.6, 198540.1, 621875.5, 10e10]
y = [1.2, 1.001, 0.746, 0.609, 0.481, 0.387, 0.38, 0.272, 0.166, 0.153, -0.164, -0.2]
staircase2 = tools.connect_points(zip(x, y))
pfaest2 = models.PFAExtTiming(models.EloModel(), time_effect_fun=staircase2,
gamma=2.554, delta=-0.766)
pfaest2_test = PerformanceTest(pfaest2, data).run()
pfaest2_test.get_results()
Out[11]:
In [33]:
pfaest2_test.get_results(only_new)
Out[33]:
In [34]:
pfaest2_test.get_results(only_old)
Out[34]:
In [10]:
pfagt = models.PFATiming(models.EloModel(),
time_effect_good='pow', a=3.196, c=0.21,
time_effect_bad='pow', b=4.705, d=0.695)
pfagt_test = PerformanceTest(pfagt, data).run()
pfagt_test.get_results()
Out[10]:
In [45]:
pfagt_test.get_results(only_new)0.363359462169
Out[45]:
In [46]:
pfagt_test.get_results(only_old)
Out[46]:
In [47]:
pfagt = models.PFATiming(models.EloModel(),
time_effect_good='log', a=1.669, c=0.102,
time_effect_bad='log', b=0.914, d=0.098)
pfagt_test = PerformanceTest(pfagt, data).run()
pfagt_test.get_results()
Out[47]:
In [48]:
pfagt_test.get_results(only_new)
Out[48]:
In [49]:
pfagt_test.get_results(only_old)
Out[49]:
In [8]:
pfagt = models.PFATiming(models.EloModel(),
time_effect_good='exp', a=1.2, c=0.0017,
time_effect_bad='exp', b=1.496, d=0.012)
pfagt_test = PerformanceTest(pfagt, data).run()
pfagt_test.get_results()
Out[8]:
In [53]:
pfagt_test.get_results(only_new)
Out[53]:
In [54]:
pfagt_test.get_results(only_old)
Out[54]:
In [14]:
pfart = models.PFAResponseTime(models.EloModel(), gamma=1.299, delta=-0.951, zeta=1.916)
pfart_test = PerformanceTest(pfart, data).run()
pfart_test.get_results()
Out[14]:
In [41]:
pfart_test.get_results(only_new)0.352750053521
Out[41]:
In [42]:
pfart_test.get_results(only_old)
Out[42]:
In [ ]: